Classfile conversion into an organization of objects, and modification thereof, to effect bytecode modification

ABSTRACT

A classfile modification method is described. The classfile modification method entails converting a classfile into a collection of objects whose organization is derived from the classfile&#39;s organization. The collection of objects comprise unique objects for each method information structure found in the classfile. Each of the unique objects reference other objects in the organization. The other objects represent their corresponding unique object&#39;s method information structure&#39;s byte code instructions. The classfile modification method also entails adding at least one additional other object to an arrangement of other objects that are referenced to a unique object. The at least one additional other object corresponds to at least one byte code instruction that causes a plug-in module&#39;s handler method to provide output function treatment for the unique object&#39;s method. The classfile modification method also entails converting the resulting collection of objects into a modified version of the classfile.

Cross-reference is made to the following related patent applications,which is assigned to the same assignee as the present application:

U.S. patent application Ser. No. 10/750,066 filed on Dec. 30, 2003,titled “System and Method Employing Bytecode Modification Techniques ForTracing Services Within An Application Server” by Gregor K. Frey andNikolai G. Nikolov. U.S. patent application Ser. No. 10/749,617 filed onDec. 30, 2003, titled, “Execution of Modified Byte Code for Debugging,Testing and/or Monitoring Of Object Oriented Software” by Nikolai G.Nikolov. U.S. patent application Ser. No. 10/749,686 filed on Dec. 30,2003, titled, “Registration Method For Supporting Bytecode Modification”by Nikolai G. Nikolov and Mario Kabadiyski. U.S. patent application Ser.No. 10/750,050 filed on Dec. 30, 2003, titled, “Modification andExecution of Bytecode For Debugging, Testing and/or Monitoring VirtualMachine Based Software” by Gregor K. Frey and Nikolai G. Nikolov. U.S.patent application Ser. No. 10/750,067 filed on Dec. 30, 2003, titled,“Byte Code Modification for Testing, Debugging and/or Monitoring OfVirtual Machined Based Software” by Nikolai G. Nikolov and MarioKabadiyski. U.S. patent application Ser. No. 10/749,757 filed on Dec.30, 2003, titled, “Application Tracing Service Employing DifferentLevels of Precision for Modifying Bytecode” by Nikolai G. Nikolov. U.S.patent application Ser. No. 10/750,160 filed on Dec. 30, 2003, titled,“Interfaces and Methods Employed Within A Bytecode Modification System”by Nikolai G. Nlkolov. U.S. patent application Ser. No. 10/749,740 filedon Dec. 30, 2003, titled, “Modified Classfile Registration With ADispatch Unit That Is Responsible For Dispatching Invocations DuringRuntime Execution Of Modified Bytecode” by Nikolai G. Nikolov.

BACKGROUND

1. Field of the Invention

The field of invention relates generally to the software arts; and, morespecifically, to classfile conversion into an organization of objects,and modification thereof, to effect bytecode modification.

2. Description of the Related Art

1. Bytecode

Certain software technologies, such a Java, emphasize the use of aspecial interpreter (which may also be referred to as a “virtualmachine”) that allows generic processor instructions to be executed on aparticular type of processor. Here, each hardware platform (e.g., eachcomputer) that the generic instructions are expected to “run on”typically includes a virtual machine that is responsible for convertingthe generic processor instructions (which are typically referred to as“bytecode”) into instructions that are specially targeted for thehardware platform's particular processor(s). Software technologies thatembrace the execution of bytecode on a virtual machine may be referredto as “virtual machine-based” software.

As a classic instance of the benefit of the Java virtual machine withrespect to Internet usage, a first personal computer (PC) that ispowered by an Intel processor may download from the Internet the sameJava bytecode instructions as a second PC that is powered by a PowerPCprocessor. Here, the first PC's Java virtual machine converts the Javabytecode into instructions that are specific to an Intel processor whilethe second PC's Java virtual machine converts the same Java bytecodeinto instructions that are specific to a PowerPC processor. Thus,through the use of Java bytecode and processor specific Java virtualmachines, an Internet server is able to maintain only a single type ofcode (the Java bytecode) without concern of client compatibility.

FIG. 1 a demonstrates the standard compilation flow for generatinginstructions 105 targeted for a specific processor (“machine specificinstructions” 105) from source code 101 a, written according to avirtual machine-based language. According to the compilation flow ofFIG. 1 a, the source code 101 a is converted into bytecode 103 a by wayof a first compiling process 102. The virtual machine then interprets104 the bytecode into machine-specific instructions 105. Themachine-specific instructions are then executed 106 to implement themethods originally articulated by the source code.

2. Object Oriented Programming and Classfiles

Certain software technologies, including Java, are “object oriented.”According to an object oriented approach, the subject matter that isprocessed by a computer program is organized into classes of likeness.For example, the software used to sell items to customer X might belongto the same class of software (e.g., a class named “sales”) that is usedto sell items to customer Y. Here, given that a significant degree ofoverlap is expected to exist regarding the methods and data types usedto process sales for both customers X and Y (e.g., an “update billingabout sale” method, an “update accounting about sale” method, a “partnumber” data type, a “quantity” data type . . . etc.) it is deemed moreefficient to organize such methods and data types into a generic “sales”class from which specific instances of the class (e.g., an instance forselling to customer X and an instance for selling to customer Y) can bedefined and created.

Each specific instance of a class is referred to as an object; and, eachobject assumes the characteristics of the class from which it isdefined. Thus, a first object could be created from the generic salesclass to create a “sell to customer X” object; and, a second objectcould be created from the generic sales class to create a “sell tocustomer Y” object. Both objects would be able to execute the methodsdefined by the class. For example, the “sell to customer X” object couldexecute the “update accounting about sale” method to update anaccounting department about a sale to customer X; and, the “sell tocustomer Y” object could also execute the “update accounting about sale”method to update an accounting department about a sale to customer Y.

In general, the runtime execution of any computer program can be viewedas the execution of a sequence of methods. With respect to anobject-oriented approach, such a sequence of methods can be implementedby calling upon a sequence of objects and invoking one or more methodsat each object. In order to invoke the method of an object, arepresentation of the object is typically created beforehand. In virtualmachine-based object-oriented software environments, classfiles arebytecode level data structures from which such representations arecreated. A classfile can be viewed as a bytecode level description of aclass; and, therefore, a classfile can be used as a template for theformation of an object, at the bytecode level, that is a member of theclass. As specific methods can be attributed to specific classes, eachclassfile is made to contain the sequence of bytecode instructions thatcorrespond to each of the class's specific methods.

FIG. 1 b shows an embodiment of both a source code level classdescription 101 b and a bytecode level class description (i.e., aclassfile) 103 b for the exemplary “sales” class referred to above. Thesource code level class description 101 b of FIG. 1 b corresponds tolevel 101 a of FIG. 1 a; and, the bye code level classfile 103 b of FIG.1 b corresponds to level 103 a of FIG. 1 a. Referring to FIG. 1 b, thesource code level description of the “sales” class identifies theclass's variables 107, such as part number (PN), quantity (QTY), perunit cost ($) and the customer's identity (CUSTOMER), and includes theclass's methods such as GetMax 130, UPDATE ACCOUNTING 108, UPDATEBILLING 109, which are articulated as source code software routines.

Compilation 102 of the source code level class description 101 b resultsin the formation of the bytecode level classfile 103 b. Among otherpossible items not shown in FIG. 1 b (e.g., rev codes, constant pools, .. . . etc), a classfile 103 b may contain field information structures110 for each of the class's variables and method information structures131, 111, 112 that contain the bytecode level instructions 120 b, 113,112 for each of the class's methods. Both the source code level commandsand the bytecode level instructions for the class's methods areillustrated in FIG. 1 b as simple lines for illustrative convenience.

Over the course of discussion of various inventive aspects set forth inthe detailed description that follows, comparisons will be made againsteach of FIGS. 1 c and 1 d. FIG. 1 c illustrates, in more detail,exemplary Java source code level commands 120 a and corresponding Javabytecode level instructions 120 b for the “GetMax” method that was firstpresented in FIG. 1 b. The “GetMax” method is designed to return thegreater of two variables ‘a’ and ‘b’ (i.e., if ‘a’ is greater, ‘a’ isreturned; if ‘b’ is greater, ‘b’ is returned).

Note that both the source code level and bytecode level implementationsfor the “GetMax” method have a single entry point 140 a, 140 b (i.e.,the method starts at locations 140 a, 140 b) and a pair of exit points141 a, 142 a and 141 b, 142 b (i.e., the method can end at locations 141a, 142 a and 141 b, 142 b—noting that a “return” command/instructioncauses an output to be presented; which, in turn, can be viewed as thecompletion of the method). Those of ordinary skill will be able torecognize that: (1) the source code level depiction 120 a of the GetMaxmethod observed in FIG. 1 c articulates a method written in Java sourcecode language that returns the greater of two values (i.e., a and b);and, likewise, (2) the bytecode level depiction 120 b of the GetMaxmethod observed in FIG. 1 c articulates a corresponding method writtenin Java bytecode language that returns the greater of two values (i.e.,the values a and b which are respectively loaded on the top of anoperand stack by the initial “iload_0” and “iload_1” instructions).

A method having a single entry point 140 and a pair of exit points 141,142, like the “GetMax” method, can be represented by depiction 150 wherethe top surface 140 corresponds to an entry point of the method and sideedges 141 and 142 correspond to exit points. FIG. 1 d shows a schematicrepresentation of the process flow for an exemplary object orientedprocess. The exemplary process flow of FIG. 1 d depicts four methods205, 206, 207, 208 depicted similarly to the representation 150 observedin FIG. 1 c (noting that method_3 207 has a structure that is identicalto the structure 150 of FIG. 1 c).

Entry points are depicted at the top surfaces 209, 210, 211, 212 ofmethods 205, 206, 207, 208; and, exit points are depicted as side portsof methods 205, 206, 207, 208 (i.e., side ports 213, 214, 215 formethod_1 205; side ports 217, 218 for method_2 206; side ports 220, 225for method_3 207; and, side ports 221, 222, 223, 224 for method_4 208)and bottom ports of methods 205, 206 and 208 (i.e., bottom port 216 formethod_1 205; bottom port 219 for method_2 206; and, bottom port 226 formethod_4 208).

According to the object oriented process flow depiction of FIG. 1 d, afirst object 201 is called in order to execute method_1205; then, asecond object 202 is called in order to execute method_2 206; then, athird object 203 is called in order to execute method_3 207; then, afourth object 204 is called in order to execute method_4 208. Each ofthe methods commence at their respective entry points 209, 210, 211,212. Method_1 exits at a exit point 215, method_2 exits at exit point217, method_3 exits at exit point 220; and, method_4 exits at exit point221 endeavors.

3. Enterprise Systems

Traditional client-server systems employ a two-tiered architecture suchas that illustrated in FIG. 2 a. Applications 231 executed on the clientside 230 of the two-tiered architecture are comprised of a monolithicset of program code including a graphical user interface component,presentation logic, business logic and a network interface that enablesthe client 230 to communicate over a network 233 with one or moreservers 234. A database 232 maintained on one of the servers 234provides non-volatile storage for the data accessed and/or processed bythe application 231.

As is known in the art, the “business logic” component of theapplication represents the core of the application, i.e., the rulesgoverning the underlying business process (or other functionality)provided by the application. The “presentation logic” describes thespecific manner in which the results of the business logic are formattedfor display on the user interface. The “database” 232 includes dataaccess logic used by the business logic to store and retrieve persistentdata.

The limitations of the two-tiered architecture illustrated in FIG. 2 abecome apparent when employed within a large enterprise. For example,installing and maintaining up-to-date client-side applications on alarge number of different clients is a difficult task, even with the aidof automated administration tools. Moreover, a tight coupling ofbusiness logic, presentation logic and the user interface logic makesthe client-side code very brittle. Changing the client-side userinterface of such applications is extremely hard without breaking thebusiness logic, and vice versa. This problem is aggravated by the factthat, in a dynamic enterprise environment, the business logic may bechanged frequently in response to changing business rules. Accordingly,the two-tiered architecture is an inefficient solution for enterprisesystems.

FIG. 10 a shows an exemplary system comprised of an application server1010 and a database server 1020. Application components 1011 executed onthe application server 1010 may include, by way of example, presentationlogic and business logic components. Within a J2EE environment, thepresentation logic may contain servlets and Java Server Pages (“JSP”)interpretable by browsers on clients 1000 (JSPs/Servlets generatehypertext markup language (HTML) which is interpreted by browsers), andthe business logic may include Enterprise Java Bean (“EJB”) componentswhich are supported be EJB containers. However, as previously mentioned,the underlying principles of the invention are not limited to a Javaimplementation.

This separation of logic components and the user interface provides amore flexible and scalable architecture compared to that provided by thetwo-tier model. For example, the separation ensures that all clients 230share a single implementation of business logic 244. If business ruleschange, changing the current implementation of business logic 244 to anew version may not require updating any client-side program code. Inaddition, presentation logic 242 may be provided which generates codefor a variety of different user interfaces 240, which may be standardbrowsers such as Internet Explorer® or Netscape Navigator®.

The multi-tiered architecture illustrated in FIG. 2 b may be implementedusing a variety of different object-oriented application technologies ateach of the layers of the multi-tiered architecture, including thosebased on the Java 2 Enterprise Edition™ (“J2EE”). In a J2EE environment,the business layer 244, which handles the core business logic of theapplication, is comprised of Enterprise Java Bean (“EJB”) componentswith support for EJB containers. Within a J2EE environment, thepresentation layer 242 is responsible for generating servlets and JavaServer Pages (“JSP”) interpretable by browsers at the user interfacelayer 240 (e.g., browsers with integrated Java virtual machines).

Although the multi-tiered system illustrated in FIG. 2 b provides a moreflexible and scalable architecture, it also results in significantadditional complexity. For example, monitoring, testing and/or debuggingmultiple clusters of presentation layer servers, business layer serversand databases, and the dependencies between them requires a significantamount of management overhead. As such, the ability to efficientlymonitor, test and/or debug object-oriented, virtual-machine-basedenterprise software, such as the software employed in a J2EEenvironment, is critical for efficient software development and/orimplementation.

SUMMARY

A classfile modification method is described. The classfile modificationmethod entails converting a classfile into a collection of objects whoseorganization is derived from the classfile's organization. Thecollection of objects comprise unique objects for each methodinformation structure found in the classfile. Each of the unique objectsreference other objects in the organization. The other objects representtheir corresponding unique object's method information structure's bytecode instructions. The classfile modification method also entails addingat least one additional other object to an arrangement of other objectsthat are referenced to a unique object. The at least one additionalother object corresponds to at least one byte code instruction thatcauses a plug-in module's handler method to provide output functiontreatment for the unique object's method. The classfile modificationmethod also entails converting the resulting collection of objects intoa modified version of the classfile.

BRIEF DESCRIPTION OF THE DRAWINGS

A better understanding of the present invention can be obtained from thefollowing detailed description in conjunction with the followingdrawings, in which:

FIG. 1 a shows a compilation process that involves bytecode levelcoding;

FIG. 1 b shows an embodiment of a source code level class descriptionand an embodiment of a bytecode level class description;

FIG. 1 c shows an embodiment of coding for a method at the source codelevel and an embodiment of coding for a method at the bytecode level;

FIG. 1 d shows an exemplary depiction of the runtime execution of anobject oriented programming language;

FIG. 2 a illustrates a traditional two-tier client-server architecture.

FIG. 2 b illustrates a multi-tier client-server architecture implementedon an enterprise network.

FIG. 3 illustrates a system architecture that embraces bytecodemodification;

FIG. 4 a shows a method that modifies bytecode in order to supportsoftware debugging and/or monitoring;

FIG. 4 b shows an example of the runtime execution of object orientedsoftware having modified bytecode for purposes of “application tracing”or debugging or “application coverage” monitoring;

FIG. 5 a shows a runtime depiction of debugging/monitoring softwarehaving bytecode modification at a method entry point;

FIG. 5 b shows a runtime depiction of debugging/monitoring softwarehaving bytecode modification at a method exit point;

FIG. 6 a shows an embodiment of coding, at the source code and bytecodelevels, for a method that has been modified for debugging and/ormonitoring purposes;

FIG. 6 b shows an embodiment of a classfile that has been modified fordebugging and/or monitoring purposes;

FIG. 7 shows an embodiment of an architectural perspective for dispatchunit software that interfaces between bytecode modified methods and plugin handlers;

FIG. 8 illustrates an exemplary set of bytecode modification pluginsemployed in one embodiment of the invention;

FIG. 9 a illustrates an invocation tree for displaying bytecode modifiedmethod invocations employed in one embodiment of the invention;

FIG. 9 b–e illustrate one embodiment of a graphical user interface forviewing information related to modified bytecode;

FIGS. 10 a–b illustrate one embodiment of the invention used toimplement a distributed statistical records (“DSR”) service;

FIGS. 11 a–b illustrate another embodiment of the invention used toimplement a distributed statistical records (“DSR”) service;

FIG. 12 illustrates one embodiment of the invention for collectingmethod invocation data related to a specific components of a Web server;

FIG. 13 illustrates a markup language converter for converting a methodinvocation tree into a markup language format (e.g., such as XML orHTML).

FIG. 14 shows a methodology for modifying bytecode for purposes ofsoftware debugging and/or monitoring;

FIG. 15 a shows a depiction of an “object tree” that is representativeof a bytecode level method prior to its modification;

FIG. 15 b shows a depiction of an “object tree” that is representativeof a bytecode level method after its modification;

FIG. 16 shows a method for modifying an object tree that isrepresentative of a bytecode level method so as to reflect the bytecodemodification to be made to the bytecode level method;

FIG. 17 shows a plurality of classsfiles registering with a dispatchunit;

FIG. 18 shows specific methodologies that can be executed when aclassfile registers with a dispatch unit.

FIGS. 19 a–g illustrate different user interfaces and techniques formodifying bytecode.

DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS

1.0. Architectural Overview

FIG. 3 and FIGS. 4 a–b describe techniques that can be directed to thetesting, debugging and/or monitoring of sophisticated object-orientedvirtual machine-based software. Throughout the description, for thepurposes of explanation, numerous specific details are set forth inorder to provide a thorough understanding of the present invention. Itwill be apparent, however, to one skilled in the art that the presentinvention may be practiced without some of these specific details. Forexample, while the embodiments described below focus on a Javaenvironment in which Java “bytecode” is processed by a Java “virtualmachine,” various underlying principles may be implemented ininterpreted-code and non-interpreted-code environments as well as objectoriented and non-object oriented environments.

FIG. 3 illustrates an embodiment of a service 355 capable of testing,debugging and/or monitoring the bytecode 350 of a sophisticated“enterprise” software platform. The service includes a bytecode modifiermodule 352 for inserting function calls at entry points and exit pointsof certain specified methods of the bytecode 350, to generate modifiedbytecode 353. As described in greater detail below, the bytecodemodifier module 352 may modify the bytecode 350 prior to runtime (see,e.g., FIG. 4 a and associated text). In this embodiment, each functioncall inserted into the modified bytecode 353 invokes a dispatch unit330; which, in turn, is responsible for directing the direction of theruntime process flow to one or more appropriate plug-in modules (e.g.,any one or more of plug-in modules 360 ₁ through 360 _(Z)). In anembodiment, the plug-in modules 360 ₁ through 360 _(Z) each includecorresponding plug-in handlers 331 ₁–331 _(N). The handlers 331 ₁–331_(N) can often be viewed as grains of executable code that outputinformation 381 ₁–381 _(N) related to the operation of the originalsoftware 350. Plug-in modules can be viewed as wrappers for the grainsof handler code.

Developers, based on their particular testing, debugging and/ormonitoring needs, may customize design and implement plug-in modules.This modular plugin architecture provides a flexible and scalablesolution for evaluating program code, and may be particularly useful forevaluating program code on large enterprise platforms (e.g., such asJ2EE-based platforms).

One particular type of function performed by a plug-in handler is anoutput function that records one or more properties about the methodand/or causes one or more properties associated with the method to berecorded. For example, one type of output function performed by aplug-in handler (e.g., plug-in handler 331 ₁) involves recording thetime that each method started at an entry point and/or exited at an exitpoint. Developers may use this recorded timing information to determine,for example, the sequence of methods just prior to a “crash” of thesoftware. Similarly, if a particular method or sequence of methods takean inordinate amount of time to complete, the developer may determinethe reasons why and/or change the program code to operate moreefficiently. As such, the recording of when method entry points andmethod exit points are reached allows a precise method history sequenceto be reconstructed.

In addition to timing information, the parameters that are passed to amethod when it starts (e.g., its input parameters) and/or the parametersthat are passed by a method when it exits (e.g., its output/returnedvalues) may also be recorded by a plug-in handler to enhance therecorded history of the execution flow (e.g., a returned value or athrown exception). For example, applications may often crash because ofan incorrect or incompatible parameter value. By recording parametervalues that are passed in and out of the application's methods over thecourse of the application's execution flow, the appearance and/or sourceof an incorrect/incompatible parameter value can be readily flagged.

Thus, not only can start/stop times be recorded on a method-by-methodbasis; but also, parameters can be recorded on a method-by-method basis.Of course, the identity of the methods themselves may also be recorded.A plug-in handler that records the start and/or end times of a methodand/or records the parameter flow in and/or out of a method may bereferred to as a “tracing” plug-in handler because aspects of the methodhistory of a software routine can be “traced” through the recordation ofits method start/end times and its method parameter values.

Another type of output function that may be performed by a plug-inhandler (e.g., plug-in handler 331 ₂) involves maintaining a counter foreach bytecode modified method and incrementing the counter each time itscorresponding method is used (e.g., incrementing the counter for abytecode modified method each time the bytecode modified method makes afunction call to the dispatch unit 330 from its entry point). Asapplications (and, in particular, enterprise applications) involvecomplicated “logic,” cross-method interdependencies, etc., it ispossible that certain sections of code are never executed (i.e., are“dead” or “unreachable”) or are almost never executed because of a flawin the design of the application.

Counting each time a method is used allows dead/unreachable or hardlyused regions of the software to be readily identified. In addition, formonitoring purposes, counting each time a method is used allows asoftware manager to comprehend “usage” rates of the software'sindividual methods. A plug-in handler that is capable of maintaining acounter for an individual method may be referred to as a “coverage”plug-in handler because the frequency of usage of various regions of thesoftware can be gauged by counting each time a method is used. Inrelated embodiments, a single coverage plug-in handler may be designedto maintain separate counters for a plurality of methods.

In the examples described herein, the various functional componentsillustrated in FIGS. 3 and 4 b operate together as a service (e.g., aJ2EE service) which may be used by programmers and/or developers totest, debug and/or monitor program code on an enterprise network usingbytecode modification techniques.

2.0. Modified Byte Code Runtime Flow

FIG. 4 a shows one embodiment of a compilation and execution methodologyfor the bytecode modification strategy outlined above. According to themethodology of FIG. 4 a, the source code of an object-oriented virtualmachine-based software technology (e.g., Java) is compiled 451 into itscorresponding bytecode. The bytecode is then modified 452 by insertingadditional bytecode instructions at method entry and exit points. Theadditional bytecode instructions invoke (e.g., make a function call to)a dispatch unit such as the dispatch unit 330, 430 illustrated in FIGS.3 and 4 b.

Once the methods to be modified have been modified 452, the modifiedbytecode is executed 453 with the help of a virtual machine interpreter.The execution of the bytecode may also be referred to as “runtime”.During runtime 453, as explained in more detail further below, thedispatch unit 330, 430 responds to each invocation from a modifiedmethod by ensuring that the runtime execution process flows to theappropriate plug-in(s) for the invoking method. As a consequence, theinvocations made to the dispatch unit 330, 430 cause the appropriateplug-in handler(s) to perform their designated functions (e.g., such asthe output functions described above). Note that each plug-in handlercan be viewed as including a specialized body of instructions that, whenexecuted, cause the plug-in handler's particular function to beperformed.

For the purpose of illustration, one example of system operation is setforth in FIG. 4 b. Like FIG. 1 d, FIG. 4 b shows a schematicrepresentation of a process flow for an exemplary object-orientedprocess. However, in contrast to FIG. 1 d, FIG. 4 b graphicallyillustrates each of the bytecode modified methods 405 through 408invoking the dispatch unit 430 at the their corresponding entry point(i.e., entry points 409 through 412) and exit point (i.e., exit points413 through 426).

Thus, as a consequence of the bytecode modification, for a process flowthat performs the substantive equivalent of that observed in FIG. 1 d(i.e., from object_1/method_1 401/405 to object_2/method_2 402/406 viaexit point 415 of method_1 405; from object_2/method_2 402/406 toobject_3/method_3 403/407 via exit point 417 of method_2 406; fromobject_3/method_3 403/420 to object_4/method_4 404/408 via exit point420 of method_3 407; and, exiting from exit point 421 of method_4 408),the process flow is directed from each method entry and exit point tothe dispatch unit 430. The dispatch unit 430 then causes the runtimeprocess flow to flow to an appropriate plug-in handler for each methodwhose corresponding handlers perform their designated function, asdescribed herein.

Note that as bytecode modifications are made at each entry and exitpoint for each of methods 405–408, the associated plug-in handlers maystill record information for each of methods 405–408 even if the runtimeprocess flow were to flow through a different set and/or sequence ofmethod entry and exit points than those observed in FIG. 4 b.

In the particular example illustrated in FIG. 4 b, methods 405, 406 and408 have been configured to receive “tracing” treatment by plug-inmodule A 460; and, only method 407 is configured to receive both“tracing” treatment and “coverage” treatment by plug-in module B 470. Assuch, the process flow for methods 405, 406 and 408 involves from eachof their respective entry 409, 410, 412 and exit 415, 417, 421 points:(1) invoking the dispatch unit 430; (2) dispatching the invocation toplug-in module A 460; (3) executing tracing method(s) with the handler461 of plug-in module A 460 (e.g., record a start time and/or inputparameters identified with the invoking method if the invoking method isinvoking from an entry point; or, record an end time and/or outputparameters and/or returned value identified with the invoking method ifthe invoking method is invoking from an exit point); and, (4) returningback to the entry or exit point that made the original invocation.

By contrast, the process flow for method 407 involves from its entry 411and exit 420 points: (1) invoking dispatch unit 430; (2) dispatching theinvocation to plug-in module B 470; (3) executing tracing method(s) withhandler 462 (i.e., record a start time and/or input parameters ifinvocation is from entry point 411; or, record an end time and/or outputparameters if invocation is from exit point 420); (5) executing coveragemethod(s) with handler 463 (i.e., increment a counter maintained formethod_3 407) and, (5) return back to the entry or exit point that madethe original invocation.

The above example demonstrates that the embodiment of the dispatch unit430 referred to above is responsible for being conscious of anappropriate plug-in module for each invoking method and causing theruntime process flow to be directed to the appropriate plug-in modulefor each invoking method. As observed in FIG. 4 b, the same plug-inmodule (e.g., plug-in module 460) may be “re-used” across a plurality ofmethods (e.g., methods 405, 406 and 408); and, some plug-in modules maycontain only a single handler (such as plug-in module 460) while othersmay contain more than one handler (such as plug-in module 470).Moreover, as described in more detail below, more than one plug-inmodule may be associated and dispatched to from the entry point and/orexit point of a single method.

Note that appropriate coverage monitoring may be gained by the coverageplug-in handler 463 at either a method's entry point or a method's exitpoint (e.g., rather than executing the coverage plug-in handler 463 atboth the method's entry and exit points as suggested by FIG. 4 b). Thatis, as the coverage plug-in handler 463 counts each time method 407 isused, a proper count may be determined by incrementing the countermaintained for method 407 only when method 407 starts (i.e., coverage istriggered at entry point 411); or, only when method 407 ends (i.e.,coverage is triggered at exit point 408). In one embodiment, coverage istriggered at entry point 411 to ensure that the count that is maintainedfor method 407 is accurate even if the software happens to crash duringexecution of method 407.

FIGS. 5 a and 5 b illustrate one embodiment of the interaction betweenthe dispatch unit and an invoking method. Specifically, FIG. 5 a depictsan embodiment of an invocation stemming from a modification made at amethod's entry point and FIG. 5 b depicts an embodiment of an invocationstemming from a modification made at a method's exit point. According tothe methodology of FIG. 5 a, a bytecode modified method starts 501(e.g., by having another method invoke it) and an initial block ofbytecode-level instructions 502 corresponds to the modification thatinvokes the dispatch unit. Alternate embodiments may choose (forwhatever reason) to insert the block of instructions for invoking thedispatch unit deeper down into the instructions that are inevitablyexecuted once the method starts.

In response to the invocation, the dispatch unit 430 identifies theappropriate plug-in module for the method through recognition of theinvoking method (e.g., by way of a class ID and a method ID) and causesthe process flow to be dispatched to an appropriate plug-in module 503by returning a reference to the appropriate plug-in module for theinvoking method (e.g., a reference to an object that the plug-in modulecorresponds to). The invoking method uses the reference to call upon theplug-in module; which, in turn, causes the plug-in module's handlermethod(s) to be executed. The handler(s) execute their recordationmethod(s) 504; and, the process flow returns to the remainder of theinvoking method's instructions 505. In the case of FIG. 5 a where thefirst block of bytecode-level instructions 502 in the modified methodare for invoking the dispatch unit, the first instruction in theremainder of the invoking method's instructions 505 may be the firstinstruction generated for the method by the standard sourcecode-to-bytecode compilation 451 process (i.e., the first instruction ofthe method prior to modification).

According to the methodology of FIG. 5 b, a bytecode-modified method canexit 510 as a consequence of various events (e.g., the method calculatesa value to be returned, the method invokes another method, etc.). In theparticular embodiment of FIG. 5 b, the block of bytecode levelinstructions 507 that correspond to the modification that invokes thedispatch unit is located just prior to an instruction 510 thatcorresponds to an exit from the method. Alternate embodiments may choose(for whatever reason) to insert the block of instructions that invokethe dispatch unit at a point deeper up into the method's sequence ofinstructions that are inevitably executed if the method is to reach theexit point 510.

In response to the invocation at the method's exit, the dispatch unitidentifies the appropriate plug-in module for the method throughrecognition of the invoking method and provides back to the invokingmethod a reference to the appropriate plug-in module. The invokingmethod uses the reference to call the appropriate plug-in module 508.The plug-in module's handler(s) execute their recordation method(s) 509;and, the process flow returns to exit the method.

3.0. Example of Modified Bytecode

FIG. 6 a illustrates a “bytecode modified” version 620 b of the bytecodelevel “GetMax” method 120 b that was originally shown in FIG. 1 c. Thatis, the bytecode modified version 620 b of FIG. 6 a can be viewed as aresult of running the instructions for the “GetMax” method 120 b throughthe bytecode modification process 452 of FIG. 4 a. Note that a schematicrepresentation of the modified “GetMax” method 650 (where blocks 643 b,644 b, 645 b and 646 b represent the additional bytecode instructions)is also shown in FIG. 6 a and may be compared with the “GetMax”structure 150 originally shown in FIG. 1 c for the purpose ofillustration.

For additional information and ease of understanding, an equivalentsource code method 620 a that could be compiled to directly produce thebytecode modified 620 b version is also shown in FIG. 6 a. Theequivalent source code method 620 a has been provided because sourcecode syntax is generally considered easier to follow than bytecodesyntax. It should be realized, however, that the equivalent source code620 a need not be generated for complying with the underlying principlesof the invention (i.e., only bytecode-level methods, such as bytecodelevel method 620 b, may be used for modification purposes).

Comparing the pre-modification bytecode method 120 b of FIG. 1 c withthe post modification bytecode method 620 b of FIG. 6 a, note thatadditional blocks of instructions 643 b, 644 b, 645 b and 646 b havebeen introduced by the bytecode modification process 452. Recalling thatthe modification process involves adding instructions that invoke thedispatch unit 430, and that the code observed in FIG. 1 c and FIG. 6 aare written in the Java language, each of the additional blocks ofinstructions 643 b, 644 b, 645 b and 646 b correspond to blocks ofbytecode-level instructions that are designed to at least invoke thedispatch unit 430.

FIG. 6 a, as an example, shows an “invokestatic” instruction beingassociated with each block of additional instructions. In the Javabytecode language, the “invokestatic” instruction is used to invoke astatic method of a particular class. A static method is a method thatbelongs to a particular class but does not require an object of theclass to be called upon in order for the method to be executed.Accordingly, use of the invokestatic instruction suggests that thedispatch unit 430 of FIG. 4 may be constructed as a class (e.g., a“dispatch” class) having static methods that are invoked by the modifiedmethods. Note that other approaches are possible so that the dispatchunit methods need not be static methods while still complying with theunderlying principles of the invention. For example, the invoked methodsmay be associated with called upon objects (in which case, for Javaapplications, “invokevirtual” or “invokespecial” invoking instructionsmay be used).

Blocks of instructions 643 b through 646 b are shown in FIG. 6 abecause, typically, some instruction level processing is performed priorto a jump to an invoked method. This pre-processing helps “set up” theprocess flow jump. For example, methods typically require inputparameters (which may also be referred to as “arguments”) that are usedas a basis for execution. At the bytecode level, the arguments forinvoking the dispatch unit's methods should be suitably prepared justprior to the actual invocation instruction (e.g., an invokestaticinstruction).

This may involve, for example, the placing of these arguments on top ofan operand stack. In a further embodiment, because the dispatch unit 430may also be geared to recognize the invoking method based upon (at leastin part) the invoking method's own arguments, the additionalinstruction-level processing that sets up the invocation to the dispatchunit may also create an object made to contain the invoking method's ownarguments (note that this same object may then be used by a plug-inmodule's handler to record the invoking method's arguments at the timethe method starts). Regardless of how the arguments for the dispatchunit's methods are prepared, the procedures for doing so require theexecution of instructions; and, therefore, modifying a bytecode-levelmethod with invocations to another method typically requires additionalinstructions, per invocation, beyond each specific invocationinstruction (e.g., beyond each added invokestatic instruction).

Because invocations to the dispatch unit are made from modified methodentry and exit points, FIG. 6 a shows the bytecode modification as theinsertion of instruction blocks at the entry and exit points of themethod 620 b. With respect to the exit points, instruction block 644 bis placed at the exit caused by the value “a” being returned; andinstruction block 645 b is placed at the exit caused by the value “b”being returned (recalling that the method is designed to returnwhichever of a and b is the greater value). Because (for purposes ofillustrative convenience) the variable stack values for the bytecodelevel methodology 620 b of FIG. 6 b have not been provided, theparameters associated with the inserted instruction blocks 643 b, 644 bthat invoke the dispatch unit are better understood by referring to theequivalent source code syntax 620 a.

Note that two different methods of the dispatch unit are invoked:dispatchunit.entry 643 a and dispatchunit.exit 644 a, 644 b. Here, thedispatchunit.entry method 643 a is invoked for those invocations madefrom a method entry point; and, the dispatchunit.exit method 644 a isinvoked for those invocations made from a method exit point. Invokingdifferent methods depending on whether the method is at an entry pointor exit point allows for different or customized dispatch unit responsesdepending on whether the method resides at an entry or exit.

Other possible differences between the entry and exit method embodimentsreferred to in FIG. 6 a may be recognized by focusing on the differencesin their arguments. Specifically, note that the embodiment of the .entrymethod 643 a includes the following arguments:

1. classid;

2. methodid;

3. object this pointer; and,

4. object [ ] param.

By contrast, the embodiments of the exit methods 644 a, 645 a includethe following arguments:

1. classid;

2. methodid;

3. returned value

4. thrown exception [which is normally null, and becomes non-null whenthe method has returned abruptly, i.e. by throwing an exception]

From the above note that both the entry and exit methods include anidentification of the class that the invoking method 620 belongs to(classid) and an identification of the invoking method 620 itself(methodid). In an embodiment, the classid and methodid parameters aresufficient to identify the invoking method. In other embodiment,however, the classid, the methodid and a description of the invokingmethod's own arguments (which are referenced through an objectidentified by the “object [ ] param” argument) are used by the dispatchunit's entry method to identify the appropriate plug-in moduletreatment. As alluded to above with respect to FIGS. 5 a and 5 b and asdescribed in more detail below with respect to FIG. 7, the dispatch unit430 maintains information that correlates each method with the one ormore plug-in modules that are supposed to treat it.

The entry method and exit methods may differ, however, in that the.entry method may also identify (e.g., via the “object this pointer”argument) the object associated with the invoking method (noting that ifthe invoking method is a class (i.e. static) method the “object thispointer” argument may be represented as a null); yet, the .exit methodmay make no such identification. As described above with respect to theembodiments of FIGS. 5 a–b, a reference for an appropriate plug-inmodule may be returned to an invoking method in response to the invokingmethod's initial call of the dispatch unit's .entry method. In order toreturn the reference to the invoking method, the identity of the objectto which the invoking method belongs should be known to the dispatchunit. Once the identity is known by the dispatch unit, it need not berepeated. Better said, the identity of the object to which the callingmethod belongs can be grasped by way of the .entry method; and,therefore, can be thereafter used by the dispatch unit for thesubsequent .exit method.

The “object this pointer” parameter therefore does not need to beprovided for .exit methods. The .entry method and exit methods may alsodiffer in that the .entry method may describe the invoking method's ownarguments as part of its invocation to the dispatch unit (i.e., in thecase of the “GetMax” method, a and b as found in “object[param]”),whereas the .exit methods may only describe the returned output value aspart of the invocation. This allows for different plug-in moduletreatment as between entry points and exit points of the same method. Inone embodiment of the invention, if a method throws an exception, an.exit method event may be processed.

Referring back to the bytecode instruction level coding 620 b, note thata third exit point and associated instruction level coding is alsodepicted 646 b. According to the approach alluded to in FIG. 6 a, thethird exit point and associated instruction level coding 646 bcorresponds to an additional exit point that is added by themodification process 452 so as to effectively install a “catch block”around the entire method. A “catch block” is coding that automaticallycauses the software process flow to jump to a section of the codingdesigned to deal with errors (e.g., a location in the bytecode of amethod) if an error occurs in the execution of the coding surrounded bythe “try-catch” block (which, in the embodiment of FIG. 6 a, correspondsto the entire GetMax method).

In summary, the modification process 452 implemented by bytecodemodifier 352, besides installing blocks of instructions 643 b, 644 b,645 b for dispatching unit invocations at naturally existing methodentry and exit points, may also be configured to install an artificialexit (i.e., one that would not exist were it not for the modificationprocess) and associated instructions that are tailored to respond to anerror condition, should one arise, during execution of the method. Insuch a case, the “i cmp” instruction (which is the instruction thatsignifies whether “a” is greater than “b” or if “b” is greater than “a”)triggers an error condition; which, in turn, would cause instructions646 b to be executed.

Referring to both the bytecode level 620 b and source code level 620 acodings of the GetMax method, note that the error handling instructions646 b correspond to an invocation to the dispatch unit 430. Here, an.exit method is used to invoke the dispatch unit. Note that a “thrown”value (i.e., an error indication) is provided as part of the invocation.This allows a unique plug-in module to be utilized to in the case of anerror condition. The error handling instructions 646 b also include ageneric thrown command that, when executed, raises an error state in thecurrent thread, which can either be caught or propagated up theexecution stack.

FIG. 6 b provides an overview of other bytecode-level modifications thatmay be made by the modification process 452 of FIG. 4 a. FIG. 6 b showsa depiction of an unmodified classfile (e.g., a classfile produced bythe compilation process 451 of FIG. 4 a). Here, it may be worthwhile torecall the discussion of the classfile 103 b provided in the Backgroundwith respect to FIG. 1 b. From this discussion, it should be apparentthat the raw classfile 650 a may be made to include other features thathave been obviated from FIG. 6 b for illustrative convenience (e.g.,field information structures, data information structures, other methodinformation structures, . . . etc).

The unmodified classfile 650 a in FIG. 6 b shows both an unmodifiedconstructor method information structure 651 a and a depiction of theunmodified information structure for the “GetMax” method 652 a. Aconstructor method is a method which is always executed with thecreation of an object. In a typical application, a constructor method isexecuted in order to initialize the other method (such as settingvariables to specific values). The constructor method 651 a associatedwith unmodified classfile may be viewed as being necessary to executebefore the execution of the GetMax method or another method found withinclassfile 650 a.

The exemplary bytecode modified classfiile 650 b includes the followingelements: (1) a “classid” field information structure 657; (2) a methodinformation structure 656 for a method that registers with the dispatchunit when the modified classfile 650 b is loaded during runtimeexecution; (3) a method information structure 651 b for a modifiedversion 653 of the constructor method; and (4) a method informationstructure 652 b for the modified version of the GetMax method 620 b thatwas discussed above with respect to FIG. 6 a. A discussion of eachfollows immediately below.

The additional classid field information structure 657 and theadditional method information structure 656 (for the dispatch unitregistration method) will be discussed together. Specifically, in anembodiment, when the modified classfile 650 b is loaded it automaticallyregisters with the dispatch unit. In a further embodiment, theregistration process entails providing the dispatch unit with the nameof the class that the classfile 650 b represents, the name of itsmethods and the number and type of each method's arguments. In return,the dispatch unit provides the classfile with a numeric “classid” valuethat is to be used for invocations made to the dispatch unit during aruntime invocation. The classid value then becomes part of theclassfile's constant pool. Accordingly, the additional methodinformation structure 656 may include instructions for the registrationmethod described just above; and, the classid information structure isused for the returned numeric “classid” parameter provided by thedispatch unit.

Viewing the constructor method prior to modification as a simple“straight through” method having a single entry point and a single exitpoint, FIG. 6 b indicates that the instructions 653 for the method maybe modified so as to include a block of instructions 654 at its entry toinvoke the dispatch unit; and, a block of instructions 655 at its exitto invoke the dispatch unit. Here, the handler(s) of the appropriateplug-in module(s) (that are called upon as a consequence of invocationsmade to the dispatch unit from additional instruction blocks 654, 655)may be tailored to report the initialized values for a method asdetermined by the constructor method. The exit block of instructions 655may also be followed by another block of instructions that correspond tothe placement of a try-catch block around the constructor method. Themodified version of the GetMax method 620 b has already been discussedwith respect to FIG. 6 a.

4.0. Dispatch Unit, Plug-In Modules and Handlers

Recall from the background that, in general, the runtime execution ofany computer program can be viewed as the execution of a sequence ofmethods; and that, with respect to an object oriented approach, such asequence of methods can be implemented by calling upon a sequence ofobjects and invoking one or more methods at each object. Referring backto FIGS. 3 and 4 b, implementing the bytecode modification approach inan object-oriented environment may take on many forms.

In one embodiment, the dispatch unit 330, 430 is implemented as a classwhose entry and exit methods are static methods of the dispatch unitclass. In this same embodiment, each of the plug-in modules 331 ₁through 331 _(N), 431 ₁ through 431 _(N) are instantiated as separateobjects from a “plug-in” class; and, the individual handlers of eachplug-in module object correspond to its operable methods.

4.1. Dispatch Unit Implementation

The dispatch unit 430 may be implemented to refer to, as illustrated inFIG. 7, a dictionary, table or similar data structure 701 (hereinafter“dictionary”) to support the dispatch unit in its central role ofdispatching invocations made by each of the modified bytecode methods toits appropriate one or more plug-in modules. The dictionary 701 of FIG.7 includes a listing of information sufficient to uniquely identity anypotential invoking or calling method (methodid and classid); and, anentry for each listing that includes a reference to the appropriateplug-in module(s). Different dictionary's may be maintained for .entryand exit methods. In further embodiments (e.g., as suggested by thesource code representations of FIG. 6 a), the information that issufficient to identify an invoking method may be made to further includearguments of the invoking method (e.g, via the “object[param]” for theentry method).

In response to the reception of the information, a method responsiblefor accessing the dictionary (e.g., a .entry or a .exit method)identifies the reference(s) that is listed for the invoking method; and,returns the reference(s) to the invoking method. Thus, from theperspective of an invoking method, an invocation is made to the dispatchunit 330, 430; which, in response, returns to the invoking method thereference to the appropriate plug-in module 331 ₁–331 _(N), 431 ₁–431_(N). The process flow then jumps to the plug-in module(s), causing thecorresponding handler instructions to be executed.

FIG. 7 shows an embodiment of a dictionary 701 that can be viewed asbeing applicable at least to the four bytecode modified methods 405,406, 407, 408 of FIG. 4 b; where, methods 405, 406 belong to the sameclass (class “1”), method 407 belong to a second class (class “2”) andmethod 408 belongs to a third class (class “3”). The dictionary liststhe appropriate plug-in module for each bytecode modified method.According to the depiction of FIG. 7, PIM_A and PIM_B represent thereferences to plug-in modules A 460 and B 470. Note that, in theembodiment of FIG. 7, each bytecode modified method is identified by itsclassid and methodid parameter set (c_(x).m_(y)). Again, in furtherembodiments, arguments of the invoking method could be included.

It is also worthwhile to point out that more than one plug-in module maybe used for any single invocation from a modified method. For example,referring briefly back to FIG. 4 b, consider a situation where the sametreatment is desired for each of methods 405 through 408 as originallydiscussed (i.e., methods 405 and 408 are to receive only tracingtreatment and method 407 is to receive both tracing treatment andcoverage treatment), however, plug-in module 470 is configured so as toonly include the coverage handler 463 (i.e., tracing handler 462 simplydoes not exist in plug-in module 470).

In this case, method 407 could still receive both tracing and coveragetreatment by configuring the dictionary entry for method 407 to listboth plug-in module A 460 (PIM_A) and plug-in module B 470 (PIM_B). Byso doing, the process flow of FIG. 4 b would change so as to touch uponboth of plug-in modules A and B 460, 470 for each of the invocationsstemming from bytecode modifications 411 and 420. Here, if the approachof FIGS. 5 a and 5 b were being implemented, the dispatch unit 430 wouldreturn references to both of the plug-in modules 460, 470 to method 407for each invocation to the dispatch unit.

4.2. Extensions of Plugins and GUI Viewers

As mentioned above with respect to FIG. 4 a, unique plugins may bedeveloped based on the specific needs of each user. By way of example,FIG. 8 illustrates an embodiment in which three different plugins areused: an application trace plugin 810; a user-configurable plugin 820;and a distributed statistical records (“DSR”) plugin 830.

The application trace plugin 810 of this embodiment identifies aparticular application to the bytecode modifier 452 (e.g., in responseto user input). In response, the bytecode modifier 452 modifies theentire application, by inserting function calls at entry points and exitpoints of each of the application's methods (e.g., using the bytecodemodification techniques described herein).

Following modification, the application is executed, and the applicationtrace handler 811 collects the timing data and, potentially, othermethod-related information, which it provides to a graphical userinterface (“GUI”) 453. In one embodiment, tree generation logic 840within the GUI 453 generates a method invocation tree 900 such as thatillustrated in FIG. 9 a, (which shows a method invocation tree 900 for asimple calculator application.

The invocation tree 900 graphically displays information related to eachinvoked method, such as the time that it takes each method to completeand/or parameters used for each method, in a structured hierarchy. Forthe calculator application, three separate headings 901, 910, and 920are generated, each of which identify a different thread of thecalculator application (e.g., “SAPEngine_Application_Thread_5”). Entriesfor methods associated with each application thread are arranged beneatheach respective thread heading. For example, method entry 902 isarranged directly beneath heading 901; method entries 911 are arrangeddirectly beneath heading 910; and method entry 921 is arranged beneathheading 920.

Method entries 902, 911 and 921 represent “independent” methods in thatthey are not tied to the execution of another method (i.e., they are notinvoked within the context of another method). By contrast, several“dependent” method entries 903–905, i.e., representing methods that aredependent on the method represented by entry 902, are graphicallyarranged under entry 902 within the invocation tree 900. For example,method entry 903 is dependent on method entry 902; method entry 904 isdependent on method entry 903; and method entries 905 are each dependenton method entry 904. As is known in the art, a first method is“dependent” on a second method if the first method is executed withinthe context of the second method. For example, the method represented byentry 903 is only executed within the method represented by entry 902.Thus, as indicated by dependency arrow 931, the dependency of methodsincreases as one moves towards the right within the invocation tree(i.e., methods towards the right are dependent on entries which arerelatively further to the left).

In addition, as indicated by the time arrow 930 in FIG. 9 a, in oneembodiment, the tree generation logic 840 generates the invocation tree900 so that entries towards the bottom of the invocation tree occurrelatively later in time in relation to entries towards the top of theinvocation tree. This graphical representation of method invocationsbased on time and dependency is a logical and useful way to displayinformation related to method invocations.

As mentioned above, various different types of information may bedisplayed for each entry within the invocation tree 900. In the exampleshown in FIG. 9 a, each entry includes an indication of how long themethod took to complete (i.e., based on the measured start/stop times).For example, an indication that method “CalcProxy.GetResults( )” took44,651 μs to complete is provided in method entry 903. In addition, anindication of certain input/output parameters used in the method mayalso be provided (e.g., “3,” “423,” “1” for method entry 903). Variousother types of method-related information may be included within theinvocation tree 900 while still complying with the underlying principlesof the invention (e.g., the counter value for the method).

In one embodiment, a filtering module 841 is employed to filter timingdata and other method-related information, based on the needs of the enduser. For example, a user may choose to filter all method invocationsfrom the method invocation tree 900 except for those methods associatedwith a particular application component, package or class. Similarly, inone embodiment, the filtering parameters may be applied so that onlyspecific types of method-related information are displayed within theinvocation tree 900. For example, the filtering parameters may specifythat only each method's timing information is to be displayed whereasother information (e.g., the method's input/output variables, thecounter value, . . . . etc), is to be filtered out. Thus, the filteringmodule 841 provides a more precise level of control over the types ofmethod's and the types of method-related information to be displayedwithin the graphical user interface 453.

An exemplary graphical user interface (“GUI”) for viewing informationrelated to modified bytecode is illustrated in FIGS. 9 b–e. For thepurpose of explanation, the GUI displays different aspects of themodified calculator application described above with respect to FIG. 9a. The exemplary GUI includes a first window 941 comprised of a list ofservices which may be selected by the end user. As indicated, theapplication tracing service 942 has been selected, thereby generatinginformation related to application tracing in a second window 946.

Different information related to the bytecode modification may bedisplayed in the second window via a set of tabs 944. In FIG. 9 b, forexample, an “Applications” tab is selected, thereby displaying a list ofapplications. For each application, an indication is providedidentifying whether the application is started or stopped and, ifstarted, whether the application is running in bytecode modified mode.The highlighted entry 943 indicates that the calculator application iscurrently running in bytecode modified mode. In addition, an action menu945 is illustrated which includes entries for stopping the highlightedapplication 943 or restarting the application normally (i.e., in anon-modified mode). In one embodiment, the action menu 945 includes anoption for restarting the application in bytecode modified mode (notshown) if the highlighted application is currently running in anon-modified mode.

FIG. 9 c illustrates the invocation tree 900 (initially illustrated inFIG. 9 a) within the context of the exemplary GUI. The invocation treeis shown within the second window 946 in response to user selection ofan “Invocations” tab from the set of tabs 944. FIG. 9 d illustratesinformation related to the different classes affected by the bytecodemodification of the calculator application, arranged in a logicalhierarchy 947 in response to user selection of the “Classes” tab fromthe set of tabs 94 944. Finally, FIG. 9 e provides an object view 948 ofthe modified calculator application in response to user selection of an“Objects” tab from the set of tabs 944.

It should be noted that the specific GUI-based features described aboveare for the purpose of illustration only. Information related tobytecode modification may be displayed in a variety of additional and/ordifferent ways while still complying with the underlying principles ofthe invention.

As described above, the application tracing plugin 810 instructs thebytecode modifier to modify all of an application's methods. While thismay be sufficient for tracing/debugging a relatively small application,a higher level of precision may be desirable, particularly when workingwith large enterprise applications.

Thus, in contrast to the application tracing plugin 810 which causes thebytecode modifier 452 to modify all of the methods within a particularapplication, the user-configurable plugin 820 illustrated in FIG. 8provides a finer level of granularity for tracing program flow. An“application” may be built from a plurality of packages (typically *.jarfiles in a Java environment); each package may be built from a pluralityof classes (i.e., class files); and each class include a plurality ofmethods. As indicated in FIG. 8, the user-configurable plugin 810 allowsthe end-user to identify specific packages, classes and/or individualmethods to be modified by the bytecode modifier 452, thereby providingsignificantly greater precision for tracing and debugging operations. Byway of example, if a coding problem is isolated to within a specificpackage, then only that package need be modified. Similarly, if theproblem can be isolated to within a particular class or method, thenonly that class/method need be modified. In one embodiment, thedifferent packages, classes and/or methods are selected and modified viaone of the interfaces described below with respect to FIGS. 19 a–e.

The method timing data and/or other method-related information may thenbe displayed within a method invocation tree 900 similar to thatillustrated in FIG. 9 a. For example, an output handler 821 associatedwith the user-configurable plugin 820 may be designed to provide themethod-related information to the invocation tree generation logic 840.Thus, when the user-configurable plugin 820 is employed (as opposed tothe application tracing plugin 810), the method invocation tree does notinclude entries for all of the methods of an application. Rather, itonly includes entries for methods within the particular package orclass, or the individual methods selected by the end-user.

In addition, in one embodiment of the invention, a distributedstatistical records (“DSR”) plugin 830 is employed to collectstatistical data related to program execution across applicationservers, databases and/or external systems. Several specific examples ofDSR tracing will now be described with respect to FIGS. 10 a-12, whichshows how certain critical entry/exit methods may be tracked to collectstatistical data.

FIG. 10 a shows an exemplary system comprised of an application server1010 and a database server 1020. Application components 1011 executed onthe application server 1010 may include, by way of example, presentationlogic and business logic components. Within a J2EE environment, thepresentation logic may contain servlets and Java Server Pages (“JSP”)interpretable by browsers on clients 1000 (JSPs/Servlets generate HTMLwhich is interpreted by browsers), and the business logic may includeEnterprise Java Bean (“EJB”) components which are supported by EJBcontainers. However, as previously mentioned, the underlying principlesof the invention are not limited to a Java implementation.

In the specific example shown in FIG. 10 a, certain specific methodinvocations, identified graphically as blocks 1001–1006, within theapplication components 1011 are modified to facilitate tracking ofclient requests and responses through the system. The timing for each ofthe relevant method invocations is identified in the timing diagramillustrated in FIG. 10 b.

The client's 1000's initial request triggers a first method invocation1001 within the application components 1011. The request may be, forexample, a request for a particular record within the database. Afteradditional application-layer processing, the application components 1011generate a database request via method invocation 1003 which is receivedand processed by the database components 1021. A single request/responsetransaction with a client may involve multiple method-based interactionsbetween the application server 1010 and the database server 1020. Thus,another method 1004 is invoked in response to a communication from thedatabase server 1020; a response to the database server is generated asmethod invocation 1005 and a final response from the database server1020 is received as method invocation 1006. Finally, the applicationresponds to the client via method invocation 1002 (e.g., which mayprovide a Web page containing the requested data to the client).

As indicated in FIG. 10 a, throughout the request/response transaction,each of the bytecode modified methods 1001–1006 reports statisticaltiming data and other method-related information back to the dispatchunit 430, which forwards the information to the DSR plugin 830. One ormore DSR handlers 831 associated with the DSR plugin 830 formats theinformation for the DSR system 1055 and/or provides the information tothe DSR system 1055 via a DSR interface 1040. In one embodiment, the DSRinterface 1040 translates the method-related information into a formatusable by the DSR system. The information may be stored within a set ofDSR files 1050 and/or viewed and analyzed via a DSR viewer 1060 (e.g.,to determine whether the system is operating correctly).

The method-related information may also be provided to the GUI 453 whichthen generates an appropriate method invocation tree, and/or displaysthe method-related information in one or more additional ways (asdescribed above). Although not illustrated in FIG. 8, a different DSRhandler may be employed to format and forward the DSR-based informationto the GUI 453.

FIGS. 11 a–b illustrate another embodiment of the invention in whichdistributed statistical information is collected using the bytecodemodification techniques described herein. In FIG. 11 a–b, theapplication components 1111 within the application server 1110communicate with and/or exchange data with an external system 1130(e.g., such as an R3 system designed by SAP AG) as opposed to a databaseserver as in FIGS. 10 a–b. However, similar principles apply. In thisembodiment, For example, the client's 1100's initial request triggers afirst method invocation 1101 within the application components 1111. Therequest may be, for example, a request for a particular record withinthe database. After additional application-layer processing, theapplication components 1111 generate an external request via methodinvocation 1103 which is received and processed by the external system1130. The specific format used for the external request may be based onthe type of communication protocol supported by the external system1130. Possible communication formats include (but are not limited to)remote method invocations (“RMI”) or remote function calls (“RFC”). RMIis a type of remote procedure call which allows distributed objectswritten in Java (e.g., Java services/components) to be run remotely. RFCis a communications interface which allows external applications tocommunicate with R/3 systems. It should be noted, however, that theunderlying principles of the invention are not limited to any particularcommunications protocol for communicating with an external system 1130.

The external system 1130 then processes the request and provides theresults back to the application components via method invocation 1104.Finally, the application components respond to the client 1100 viamethod invocation 1102.

As in the examples shown in FIGS. 10 a–b, each time a bytecode-modifiedmethod is invoked, timing data and other method-related information isprovided to the dispatch unit 430, which forwards the method-relatedinformation to the DSR plugin 830. The appropriate handlers (e.g.,handler 831) then format and/or forward the method-related informationto the DSR system 1055 via the DSR interface 1040. The DSR interface1040 may translate the information into a format interpretable by theDSR system, if necessary. The information may then be stored within aset of DSR files 1050 and/or viewed and analyzed via a DSR viewer 1060.In addition, as in the embodiment shown in FIG. 10 a, the method relatedinformation may also be sent to the GUI 453 for viewing within aninvocation tree and/or may be displayed in any other convenient manner.

FIG. 12 illustrates one embodiment of the invention in which thebytecode modifier 452 modifies a particular set of methods 1211–1232 totrace program flow within a J2EE engine 1250. For example, HTTP requeststransmitted by a Web-based client 1200 (e.g., a client with a Webbrowser) are processed by input/output method invocations 1227–1228 ofHTTP logic 1201. Communication between HTTP logic 1201 and servlet/JSPcomponents 1202 is accomplished via method invocations 1229, 1230 and1231, 1232, respectively. Other method invocations illustrated in FIG.12 which represent entry/exit points between different J2EE servicesinclude method invocations 1213, 1214, 1216 and 1215 between enterpriseJava bean (“EJB”) components 1203 and servlet/JSP components 1202;method invocations 1233, 1234 and 1219, 1220 between servlet/JSPcomponents 1202 and Java connector (“JCo”) components 1204; methodinvocations 1221 and 1222 between JCo components 1204 and an externalsystem 1207; method invocations 1211, 1212 and 1223, 1224 betweenservlet/JSP components 1202 and Java database connectivity (“JDBC”)components 1205; and method invocations 1225, and 1226 between the JDBCcomponents and a database 1206; and method invocations 1217 and 1218between EJB components and a non-web client 1250 (e.g., via RMI or RFCtransactions).

The specific functions performed by each of the modules/componentsillustrated in FIG. 12 are well defined and are not necessary for anunderstanding of the underlying principles of the present invention. Forexample, the JDBC component 1205 is a well known interface that allowsJava applications to access a database via the structured query language(“SQL”). The JCo component 1204 is an interface that allows a Javaapplication to communicate with systems designed by SAP AG (e.g., an R/3system). As described above, HTTP logic 1201 and servlet/JSP components1202 perform various well defined presentation-layer functions and theEJB components 1203 perform various well define business layerfunctions. Further details related to each of these modules/componentscan be found from various sources including the Java website (see, e.g.,the website located at java.sun.com).

For the purpose of the present application, FIG. 12 is significantbecause it shows how specific entry/exit points between the variousservices/components 1201–1205 may be tracked using the bytecodemodification techniques described herein. For example, the individualmethods highlighted in FIG. 12 may be selected for modification via aplugin such as the user-configurable plugin 820 illustrated in FIG. 8.As the methods are executed, timing data and other information relatedto each of the methods (e.g., method parameters) are collected by thedispatch unit 430 and forwarded to the appropriate plugin handlers(e.g., handler 821). The handler(s) then forward the information to aGUI 453 or other output destinations for analysis. If a DSR plugin 830is used, the dispatch unit 430 may forward the method information to anappropriate the DSR handler 831 which, in turn, may format and/ortransmit the information to a specified DSR system via a DSR interface(e.g., such as DSR system 1055, and DSR interface 1040, respectively).

Some end users may want to export the results of the bytecodemodification techniques described herein to a standardized format, sothat the results may be viewed and/or analyzed on other systems. To thisend, as illustrated in FIG. 13, one embodiment of the invention includesa markup language conversion module 1300 for converting the methodinvocation tree generated by the tree generation logic 840 into a markuplanguage format 1301. For example, in one embodiment, the markuplanguage conversion module 1300 converts the method timing data andother method-related information from the invocation tree into anextensible markup language (“XML”) format. XML provides a similar tagstructure as the hypertext markup language (“HTML”) used for standardWeb pages; however, while HTML defines how elements are displayed, XMLdefines what those elements contain. In addition, while HTML usespredefined tags, XML allows tags to be defined by the developer of thepage. Thus, all method-related data from the invocation tree (e.g.,method execution times, method parameters, counter values, . . . etc)may be easily represented within an XML file using a set of hierarchicaldata tags. The markup-formatted invocation data may then be viewed,edited and/or analyzed via a GUI which supports the specified markuplanguage (e.g., current browsers, if the markup language used is XML).

Instead of converting the invocation tree generated by the treegeneration logic 840 into a markup language format, one embodiment ofthe markup language conversion module 1300 receives the method-relateddata directly from the a handler 811, 821, 831. This embodiment may bemore efficient in that it circumvents the intermediate tree generationby the invocation tree generation logic 840.

5.0. Implementing Bytecode Modification

The discussions presented above focus upon characteristics of modifiedbytecode and the runtime execution flow of modified bytecode. Thepresent section, by contrast, focuses on techniques for actuallymodifying the bytecode. Better said, referring back to FIG. 4 a, whereasprior sections focused upon what the “output” of the bytecodemodification process 452 might look like and how modified bytecode mightexecute 453 during runtime, the present section focuses on methodologiesthat may be used to implement the actual bytecode modification process452. Specifically, Section 5.1 discusses techniques for modifyingclassfiles; Section 5.2 discusses dispatch unit configuration; and,Section 5.3 discusses interfaces for specifying customized plug-inmodules.

5.1 Processes for Modifying Classfiles

FIG. 14 presents a methodology that may be used to implement thebytecode modification process 452 originally presented in FIG. 4 a.Recalling the notion of classfiles originally presented in reference tothe exemplary “sales” classfile 103 b of FIG. 1 b, the methodologypresented in FIG. 14 illustrates that each classfile having at least onemethod to be modified is converted 1401 into a collection of objectsthat are organized to reflect the structure of the classfile. FIG. 15 a,as an example, illustrates how the “sales” classfile embodiment 103 b ofFIG. 1 b might be converted into such a collection of objects.

Referring to the exemplary classfile 103 b of FIG. 1 b and thecorresponding collection of objects of FIG. 15 a, note that the“hierarchy” of objects observed in FIG. 15 a attempts to mirror thehierarchy of the bytecode level classfile 103 b illustrated in FIG. 1 b.Object oriented programming has an “inheritance” property by whichobjects of a class inherit the properties defined for a class (e.g., thetypes of variables that the object can entertain specific values for).Given the existence of the inheritance property, FIG. 15 a attempts todemonstrate an example of how the various features of the “sales”classfile 101 b of FIG. 1 b may be organized into specific classes ofobjects were principles of inheritance are observed.

Specifically, FIG. 15 a suggests the creation of a separate class foreach of the major features of the “sales” classfile 103 b; and, thecreation of specific instances (i.e., objects) of these classes so as tocreate an object oriented representation of the classfile. For example,a specific class 1501 may be created for field information structuresand a specific class 1502 may be created for method informationstructures. The field information structure class 1501 can then be usedas a template to form separate “PN”, “QTY”, “$” and “CUSTOMER” objects1501 ₁, 1501 ₂, 1501 ₃, 1501 ₄ that respectively represent the “PN”,“QTY”, “$” and “CUSTOMER” field information structures 110 found in the“sales” classfile 103 b.

Likewise, the method information structure class 1502 can be used as atemplate to form separate “UPDATE ACCOUNTING”, “UPDATE BILLING” and“GetMax” objects 1502 ₁, 1502 ₂, 1502 ₃ that respectively represent the“UPDATE ACCOUNTING”, “UPDATE BILLING” and “GetMax” method informationstructures 111, 112, 131 found in the “sales” classfile 103 b. FIG. 15 aalso elaborates on the content of the GetMax object 15023. Here, themethod information structure class 1502 is assumed to specify that eachof its object offspring (e.g., objects 1502 ₁, 1502 ₂, 1502 ₃) are to beassociated with objects that correspond to bytecode level instructionsfor the method that it represents. Each of the objects 1503 observed inFIG. 15 a correspond to the listed matter maintained by the GetMaxobject 15023. Note that the listed matter observed in FIG. 15 acorresponds precisely to the bytecode level instructions for the GetMaxmethod 120 b first depicted in FIG. 1 c.

Referring back to FIG. 14, the collection of objects is then modified1403 to reflect the bytecode modifications. FIG. 15 b provides acorresponding example showing how the objects associated with the GetMaxobject 15023 of FIG. 15 a can be modified 1403 to represent the modifiedGetMax bytecode 620 b that has been provided in FIG. 6 a. Specifically,note that the listed objects has been expanded so as to include—in theirproper locations—representations of the additional bytecode instructions1504, 1505, 1506, 1507 that invoke the dispatch unit. For illustrativesimplicity, FIG. 15 b only shows the insertion of a single invocationinstruction (“invokestatic”) 1504, 1505, 1506, 1507 for each ofinstruction blocks 643 b, 6444 b, 645 b and 646 b of FIG. 6 a.

It should be recognized however that if blocks of multiple instructionsare to be inserted for each dispatch unit invocation (e.g., as suggestedby instruction blocks 643 b, 6444 b, 645 b and 646 b of FIG. 6 a); then,likewise, a corresponding list of instructions would be inserted at eachof locations 1504, 1505, 1506, 1507. FIG. 16 shows a method that can beexecuted to make modifications to a collection of objects that arerepresentative of a classfile (such as the modifications observed inFIG. 15 b) so as to reflect the appropriate modifications to be made toa method's bytecode instructions.

According to the methodology of FIG. 16, modifications are inserted thatare representative of additional instructions (e.g., a block ofinstructions) that invoke the dispatch unit at positions in thecollection of objects that represent the following method locations: 1)a method entry point 1601 (e.g., as represented by modification 1504 ofFIG. 15 b); 2) a method exit point 1602 (e.g., as represented bymodifications 1505, 1506 of FIG. 15 b); and, 3) the end of a method'sinstructions for purposes of introducing try-catch block instructions1603 (e.g., as represented by modification 1507 of FIG. 15 c).

The example referred to in FIGS. 15 a and 15 b and the methodology ofFIG. 16 indicate that specific methods may be represented by specificobjects and their corresponding bytecode instructions may be representedby other objects that they are associated with. It is important torecognize that a collection of objects configured to represent aclassfile may be modified in other aspects so as to fully represent acompletely modified classfile. For example, referring back to FIG. 6 b,recall that other bytecode level modifications may be made besidesinstalling dispatch unit invocations at method entry and exit points andbesides installing try-catch blocks around methods themselves.

Specifically, an entire method information structure may be insertedinto the classfile (such as a method information structure 656 for adispatch unit registration method); and, a new field informationstructure may be inserted into the classfile (such as a fieldinformation structure 657 for a classid value). In keeping with theapproach outlined above with respect to FIGS. 15 a and 15 b, where aseparate object is created for each method information structure and foreach field information structure, note that the insertion of anadditional method information structure would correspond to the creationof a first object in the collection of objects (e.g., a “dispatch unitregistration” object); and, the insertion of an additional fieldinformation structure would correspond to the creation of a secondobject in the collection of objects (e.g., a “classid” object).

Thus, whereas the modifications to the class methods themselves mightinvolve modifying the collection of objects associated with each objectmade to represent a method, constructing a complete collection ofobjects that are representative of a completely modified classfile mightinvolve the creation of objects having no counterpart to thepre-modified bytecode (e.g., the pre-modified bytecode has no “dispatchunit registration” method information structure nor “classid” fieldinformation structure).

Referring back to FIG. 14, irrespective of how a collection of objectsare made to represent a modified classfile, the collection of objects isconverted into a bytecode level classfile 1403. As a consequence, afully modified classfile is created. The conversion of a classfile intoa collection of objects and the reconversion of a collection of objectsinto an actual classfile is a well known process, also referred to asparsing/serialization of a classfile.

5.2. Dispatch Unit Configuration

In one embodiment of the invention, in order for the dispatch unit 330,430 to properly dispatch an invocation from a specific method to itsappropriate plug-in during runtime, the dispatch unit is configuredbeforehand with the appropriate information. For example, beforesupporting an actual runtime flow of modified bytecode, the dispatchunit 430 may run through internal processes that “set up” information(e.g., a dictionary) that correlates each bytecode modified method withone or more appropriate plug-in modules. Recall that an embodiment ofsuch a dictionary that correlated each modified bytecode method with anappropriate plug-in module has already been discussed with respect toFIG. 7. FIGS. 17 and 18 describe some possible approaches that enablethe dispatch unit 430 to configure itself to support a runtime flowinvocation from a bytecode modified method.

FIG. 17 shows a plurality of modified classfiles 1701 ₁ through 1701_(N) that each include, respectively, a “dispatch unit registration”method information structure 1703 ₁ through 1703 _(N) and a classidfield information structure 1704 ₁ through 1704 _(N). Note again that amodified classfile format having such information structures has alreadybeen referred to over the course of the discussion of FIG. 6 b.According to the depiction of FIG. 17, the method associated with eachof information structures 1703 ₁ through 1703 _(N) “registers” with thedispatch unit 1702 by sending the dispatch unit 1702 its class name, thenames of each of its methods and the types of arguments of its methods.

By way of example, as illustrated in FIG. 17, modified classfile 1701 ₁sends the dispatch unit 1702 its class name and the names and argumenttypes of each of its methods 1705 ₁; modified classfile 1701 ₂ sends thedispatch unit 1702 its class name and the names and argument types ofeach of its methods 1705 ₂; and modified classfile 1701 _(N) sends thedispatch unit 1702 its class name and the names and argument types ofeach of its methods 1705 _(N). Registration may invoke any feature ofthe dispatch unit's class such as a field, an object or a method.

In an embodiment, registration occurs as a consequence of a modifiedclassfile being “loaded.” The loading of a classfile can be viewed asthe preparing of a class for subsequent use. In a typical case, aclassfile is loaded before the classfile is used as a template forcreating an object that is a member of the class that the classfiledefines. In a further embodiment, a registration process is executed fora classfile before any of the classfile's modified methods are executed.So doing causes the dispatch unit 1702 to be properly updated for anysubsequent invocation that arises from the execution of any of theclass's modified methods.

The dispatch unit 1702 uses the class name, method names and methodspecific argument types received from any particular classfile as astimulus for updating its internal information that correlates specificmethods to specific plug-in modules (e.g., an internal dictionary). Invarious embodiments, the dispatch unit 1702 correlates class methods totheir appropriate plug-in strictly numerically (i.e., without the use ofcharacter strings). For example, the dictionary of FIG. 7 may beconfigured to reference each classid (c_(x)), each methodid (m_(x)) as anumber rather than its given character string name.

In order to reference classes and methods strictly numerically,therefore, each character string based class name (e.g., “Sales”) isconverted into a number (e.g., integer 1); and, each character stringbased method name (e.g., “GetMax”, “UPDATE ACCOUNTING”, “UPDATEBILLING”) is converted into a corresponding number (e.g., integer 1,integer 2, integer 3). FIG. 17 suggests such an approach in that eachregistering classsfile 1701, through 1701 _(N) sends its class name tothe dispatch unit (e.g., in the form of its given character string(e.g., “Sales” for classfile 1701 ₁)); and, in response, the dispatchunit 1702 returns a numeric classid 1706 ₁ through 1706 _(N) to each ofthe registering classfiles, respectively.

The numeric classids are configured into the dispatch unit's plug-incorrelation dictionary; and, subsequent invocations made to the dispatchunit 1702 by way of a modified method are made to use the numericclasssid value rather than the given character string for the name. Infurther embodiments the numeric references are embodied as integers inorder to improve processing speeds. Moreover, the numeric classid may besimply derived from the position at which a registering classfileregisters with respect to a consecutive sequence of classfiles thatregister with the dispatch unit (e.g., the first classfile to registerwith the dispatch unit is given a classid of “1”, the second classfileto register with the dispatch unit is given a classid of “2”, etc.).

With respect to the conversion of character string method names into anappropriate number, in an embodiment, both the registering classsfiles1701 ₁ through 1701 _(N) and the dispatch unit 1702 are made tounderstand that methods are referred to numerically in a sequentialorder. For example, according to one approach, the methods are referredto by the order in which their corresponding information structures arelisted in the classfile. FIG. 1 b helps to envision such an approach.Referring to FIG. 1 b (and assuming that the classfile of FIG. 1 b ismodified as observed in FIG. 6 b) note that the method informationstructures are listed in the following order: “GetMax”, “UPDATEACCOUNTING”, “UPDATE BILLING”. One way to refer to the methods in theorder of their listing in the classfile is as follows: 1) “GetMax”=integer 1; 2) “UPDATE ACCOUNTING”=integer 2; 3) “UPDATEBILLING”=integer 3. According to such an approach, the same method namesare used by different classes (i.e., classid 1 has methods 1, 2 and 3;and, class 2 has methods 1, 2, 3). Combining classid and methodid,however, will still produce unique “per method” identification.

By making the classfiles and the dispatch unit understand the sameordered numeric naming scheme, methods can be properly referencedbetween the classfiles and the dispatch unit in a manner that isconsistent with the method/plug-in-handler correlation entries that aremaintained by the dispatch unit. For example, if classfile 1701,corresponds to the “Sales” classfile of FIG. 1 b, and if, the dispatchunit 1702 returns a classid value of “integer: 1” to the “Sales”classfile 1701 1, then: 1) the modified “GetMax” method will invoke thedispatch unit 1702 with a classid,methodid set of 1,1; 2) the modified“UPDATE ACCOUNTING” method will invoke the dispatch unit 1702 with aclassid,methodid set of 1,2; and, 3) the modified “UPDATE BILLING”method will invoke the dispatch unit 1702 with a classid,methodid set of1,3. Likewise, the dispatch unit would correlate identical numericalentries listed above to the proper plug-in handler treatment for each ofthe three methods.

In an embodiment, during the registration process, a registeringclassfile sends method names in character string form to the dispatchunit 1702 in an order that allows the dispatch unit 1702 to properlydeduce the correct numeric methodid values. For example, continuing withthe above example, the “Sales” classfile 1701 ₁ would send methodcharacter string names in the following order: “GetMax”, “UPDATEACCOUNTING”, “UPDATE BILLING”. By sending the character string names inthe order listed above, both the registering classfile and the dispatchunit could independently recognize that the “GetMax” method is be givena methodid value of 1; the “UPDATE ACCOUNTING” method is to be given avalue of 2; and, the “UPDATE BILLING” method is to be given a value of3.

Even though the dispatch unit 1702 can deduce the proper numeric namingscheme simply from knowing the order of the methods, explicit characterstrings are sent to the dispatch unit 1702 to also assist the dispatchunit in the updating of its method/plug-in module correlation scheme.FIG. 18 helps explore this aspect in more detail. FIG. 18 shows aregistering classfile 1801 and a dispatch unit 1802. Consistent with thepreceding discussion concerning FIG. 17, note that the registeringclassfile 1801 can be regardred as sending 1803 the class names andmethod names 1805 in character string format (e.g., “Sales”, “GetMax”,“UPDATE ACCOUNTING”, “UPDATE BILLING”). In response, the dispatch unit'sregistration method 1807 refers to a plug-in pattern 1811 to identifywhich plug-in modules are to be applied to which methods 1808. Theplug-in pattern, in an embodiment, includes a list, for each plug-inmodule, of every method (e.g., by class name and method name incharacter string format) it is expected to treat.

For example, referring back to FIG. 4 b, recall that plug-in module A460 was configured to treat methods 405, 406 and 408 while plug-inmodule B was configured to treat only the third method 407. In such aninstance, the substantive content of the lists maintained by the plug-inpattern 1811 would be as follows:

1) PlugIn A (460):

-   -   1.1) [character string name of class for method_1 (405)],        [character string name of method_1 (405)];    -   1.2) [character string name of class for method_2 (406)],        [character string name of method_2 (406)];    -   1.3) [character string name of class for method_4 (408)],        [character string name of method_4 (408)];

2) PlugIn B (470):

-   -   2.1) [character string name of class for method_3 (407)],        [character string name of method_3 (407)];

In an embodiment, the plug-in pattern 1811 is a body of informationmaintained (e.g., by way of an object) by the same class that thedispatch unit 1802 is associated with.

Once one or more appropriate plug-in modules have been identified by thedispatch unit's registration methodology 1807, the scheme used tocorrelate specific methods to their appropriate plug-in module(s) duringruntime (e.g., dictionary 1812) is updated 1809 to account for all themethods of the registering classfile. The argument types for each methodthat are provided by a registering classfile can be added to the classidand methodid in each listing. If strictly numeric references are to beused for the classids and methodids, the character string-to-numericconversion should be performed prior to the actual update 1809. Forexample, numeric methodids should be assigned based on the order ofreception of method names from the registering classfile 1803; and, asuitable numeric classid should be identified. In an embodiment, thenumeric classid is determined simply by incrementing a counter for eachnew registering classfile. The numeric classsid is then sent 1810 to theregistering classfile 1801.

Given that the embodiment of the plug-in pattern described aboveidentifies methods through their corresponding character strings, thedispatch unit's registration method 1807 would need a registeringclassfile 1801 to identify its methods with these same character stringsso that the correct correlation between a modified method and its properplug-in treatment could be carried out. Here, the use of characterstrings is emphasized because some form of “user” 1813 (e.g., a test ordevelopment engineer or maintenance Information Science (IS) personal)ultimately determines which methods are to receive which treatment fromwhich plug-in modules.

For example, in the case of Distributed Statistical Records (DSR),typically, only a subset of eligible methods are selected formodification (e.g., “the important ones”). The intelligent selection ofspecific methods for modification ultimately boils down to their beinglisted by the plug-in pattern 1811. Accordingly, since methods andclasses are most often dealt with by a user at a source code level orhigher (e.g., GUI) with character strings—it is natural to expect that a“list” of methods to be treated as determined by a user would be listedin a character string format. Of course, in alternate embodiments, aninitial list of character string names could be pre-formulated prior toregistration so as to be represented purely in numeric form. This, inturn, may obviate registering with character strings.

5.3 Interfaces

Bytecode modification may be accomplished using a variety of differenttechniques and interfaces. As indicated in FIG. 19 a, in one embodiment,an application programming interface (“API”) of the bytecode modifier1900 is exposed, thereby providing direct access to end users. Asindicated in FIGS. 19 a and e, the API may be published, therebyproviding access the various classfiles of the API via a standard Webbrowser 1940. Similarly, as illustrated in FIGS. 19 a and f, the API maybe accessed and bytecode may be modified via a standard command lineinterface 1901. The command line interface 1901 is particularly suitablefor batch files or environments in which running a graphical userinterface (e.g., such as that described below) would be undesirable dueto weak hardware, for example, or an operating system which is primarilyconsole-oriented.

As illustrated in FIGS. 19 a and g, in one embodiment, extensions 1903are provided to the Apache Ant builder application 1902. Apache Ant is awell known open-source build tool for compiling, packaging, copying,etc.—in one word “building”—Java applications (see, e.g., the websitelocated at akarta.apache.org/ant). The extensions 1903 to the Antbuilder application 1902 allow the end user to generate modifiedbytecode as part of the build process. For example, an ant task may beparticularly suitable for automatic build scripts in which it is used tomodify one or more classes after compilation (e.g., within a J2EEengine).

In addition, in one embodiment, a wizard-based GUI is provided forsimplifying the bytecode modification process. Referring to FIG. 19 b,the user is initially provided with a source data field 1910 to identifya particular directory or file containing packages, classes or methodsto be modified; and a output data field 1911, to identify a destinationdirectory or file for the results of the bytecode modification process.In one embodiment, a check box 1912 is provided to allow the user to setthe output directory or file to be the same as the source directory orfile. In the particular example illustrated in FIG. 19 b, the userselects the “util” package, identified by the *.jar file “iq-lib jar.”

FIG. 19 c illustrates a second window 1920 which provides a hierarchicalrepresentation of information related to the “util” package. The “util”package is identified as such within data field 1921. A specific element1923 (e.g., classfile) within the tree 1924 is highlighted. As a result,methods associated with the highlighted element are displayed within atable 1922. The table includes an “identifier” column for identifyingeach method, and a “properties” column, containing (among otherproperties) an indication as to whether the method will be modified bythe bytecode modification process. For example, if the parameter“modify” is set to a binary ‘1’, then the bytecode modifier will modifythe method. By contrast, if “modify” is set to a binary ‘0’, then thebytecode modifier will not modify the method. Thus, the user may specifywhether the method is to be modified by setting the value of the“modify” parameter. Following the bytecode modification process, FIG. 19d illustrates a completion window 1930 which indicates the number ofclassfiles and method which were modified and the length of timeconsumed by the modification process.

Embodiments of the invention may include various steps as set forthabove. The steps may be embodied in machine-executable instructionswhich cause a general-purpose or special-purpose processor to performcertain steps. Alternatively, these steps may be performed by specifichardware components that contain hardwired logic for performing thesteps, or by any combination of programmed computer components andcustom hardware components.

Elements of the present invention may also be provided as amachine-readable medium for storing the machine-executable instructions.The machine-readable medium may include, but is not limited to,hard-disk drives, flash memory, optical disks, CD-ROMs, DVD ROMs, RAMs,EPROMs, EEPROMs, magnetic or optical cards, propagation media or othertype of machine-readable media suitable for storing electronicinstructions. For example, the present invention may be downloaded as acomputer program which may be transferred from a remote computer (e.g.,a server) to a requesting computer (e.g., a client) by way of datasignals embodied in a carrier wave or other propagation medium via acommunication link (e.g., a modem or network connection).

Throughout the foregoing description, for the purposes of explanation,numerous specific details were set forth in order to provide a thoroughunderstanding of the invention. It will be apparent, however, to oneskilled in the art that the invention may be practiced without some ofthese specific details.

Accordingly, the scope and spirit of the invention should be judged interms of the claims which follow.

1. A classfile modification method, comprising: before loading and usinga classfile to create an object during runtime; converting saidclassfile into a collection of objects, said collection of objectsincluding a first object that represents a method information structurefound in said classfile, said collection of objections including asecond object that inherits a property that said first object has, saidsecond object representing a bytecode instruction of a method; adding athird object to said collection of objects, said third object inheritingthe properties of said first object, said third object representing abytecode instruction to be executed by said method that, when executedby said method, invokes a pre-existing dispatcher to identify a plug-inmodule for said method that said method invokes to report and/or recordinformation about said method; adding a fourth object to said collectionof objects that represents a new method information structure for saidclassfile, said new method information structure containing byte codeinstructions for a second method that registers, with said dispatcherupon loading of said classfile, an identity of said classfile's classand respective identities of methods of said classfile, said dispatcherand plug-in module being in existence prior to said loading of saidclassfile; and, converting said collection of objects including saidthird object into a modified version of said classfile.
 2. The classfilemodification method of claim 1, further comprising adding a fifth objectto said collection of objects that represents a new field informationstructure for said classfile.
 3. The classfile modification method ofclaim 2, wherein said field information structure is to store a numericidentification assigned to said class by said dispatcher.
 4. Theclassfile modification method of claim 1, wherein said third object isadded to said collection of objects in a position that corresponds to aregion of said method's instructions that is executed just after saidmethod's entry point is reached.
 5. The classfile modification method ofclaim 4, wherein said classfile is a Java compatible classfile and saidadding of said third object corresponds to the addition of aninvokestatic instruction.
 6. The classfile modification method of claim4, wherein said classfile is a Java compatible classfile and said addingof said third object corresponds to the addition of an invokevirtualinstruction.
 7. The classfile modification method of claim 1, whereinsaid third object is added to said collection of objects at a positionthat corresponds to a region of said method's instructions that isexecuted if an exit point of said method will inevitably be reached. 8.The classfile modification method of claim 7 wherein said classfile is aJava compatible classfile and said adding of said third objectcorresponds to the addition of an invokestatic instruction.
 9. Theclassfile modification method of claim 7 wherein said classfile is aJava compatible classfile and said adding of said third objectcorresponds to the addition of an invokevirtual instruction.
 10. Theclassfile modification method of claim 1, wherein said third object isadded to said collection of objects in a position that corresponds to aregion of said method's instructions that will be executed if an errorarises during execution of said method.
 11. The classfile modificationmethod of claim 10, wherein said classfile is a Java compatibleclassfile and said adding of said third object corresponds to theaddition of an invokestatic instruction.
 12. The classfile modificationmethod of claim 10, wherein said classfile is a Java compatibleclassfile and said adding of said third object corresponds to theaddition of an invokevirtual instruction.
 13. The classfile modificationmethod of claim 1, further comprising: adding said third object to saidcollection of objects at a position that corresponds to a region of saidmethod's instructions that is executed just after said method's entrypoint is reached; adding a fifth object to said collection of objects ata position that corresponds to a region of said method's instructionsthat is executed if an exit point of said method will inevitably bereached; and, adding a sixth object to said collection of objects at aposition that corresponds to a region of said method's instructions thatwill be executed if an error arises during execution of said method. 14.The classfile modification method of claim 13, wherein said classfile isa Java compatible classfile and said third, fifth and sixth objectscorrespond to the addition of invokestatic instructions.
 15. Theclassfile modification method of claim 13, wherein said classfile is aJava compatible classfile and said third, fifth and sixth objectscorrespond to the addition of invokevirtual instructions.
 16. A machinereadable storage medium containing instructions which when executedcause a classfile modification method to be performed, said classfilemodification method comprising: before loading and using a classfile tocreate an object during runtime; converting said classfile into acollection of objects, said collection of objects including a firstobject that represents a method information structure found in saidclassfile, said collection of objections including a second object thatinherits a property that said first object has, said second objectrepresenting a bytecode instruction of a method; adding a third objectto said collection of objects, said third object inheriting theproperties of said first object, said third object representing abytecode instruction to be executed by said method that, when executedby said method, invokes a pre-existing dispatcher to identify a plug-inmodule for said method that said method invokes to report and/or recordinformation about said method; adding a fourth object to said collectionof objects that represents a new method information structure for saidclassfile, said new method information structure containing byte codeinstructions for a second method that registers, with said dispatcherupon loading of said classfile, an identity of said classfile's classand respective identities of methods of said classfile, said dispatcherand plug-in module being in existence prior to said loading of saidclassfile; and, converting said collection of objects including saidthird object into a modified version of said classfile.
 17. The machinereadable storage medium of claim 16, wherein said classfile modificationmethod further comprises adding a fifth object to said collection ofobjects that represents a new field information structure for saidclassfile.
 18. The machine readable storage medium of claim 17, whereinsaid field information structure is to store a numeric identificationassigned to said class by said dispatcher.
 19. The machine readablestorage medium of claim 16, wherein said third object is added to saidcollection of objects in a position that corresponds to a region of saidmethod's instructions that is executed just after said method's entrypoint is reached.
 20. The machine readable storage medium of claim 19,wherein said classfile is a Java compatible classfile and said adding ofsaid third object corresponds to the addition of an invokestaticinstruction.
 21. The machine readable storage medium of claim 19,wherein said classfile is a Java compatible classfile and said adding ofsaid third object corresponds to the addition of an invokevirtualinstruction.
 22. The machine readable storage medium of claim 16,wherein said third object is added to said collection of objects at aposition that corresponds to a region of said method's instructions thatis executed if an exit point of said method will inevitably be reached.23. The machine readable storage medium of claim 22, wherein saidclassfile is a Java compatible classfile and said adding of said thirdobject corresponds to the addition of an invokestatic instruction. 24.The machine readable storage medium of claim 22, wherein said classfileis a Java compatible classfile and said adding of said third objectcorresponds to the addition of an invokevirtual instruction.
 25. Themachine readable storage medium of claim 16, wherein said third objectis added to said collection of objects in a position that corresponds toa region of said method's instructions that will be executed if an errorarises during execution of said method.
 26. The machine readable storagemedium of claim 25, wherein said classfile is a Java compatibleclassfile and said adding of said third object corresponds to theaddition of an invokestatic instruction.
 27. The machine readablestorage medium of claim 25, wherein said classfile is a Java compatibleclassfile and said adding of said third object corresponds to theaddition of an invokevirtual instruction.
 28. The machine readablestorage medium of claim 16, wherein said classfile modification methodfurther comprises: adding said third object to said collection ofobjects at a position that corresponds to a region of said method'sinstructions that is executed just after said method's entry point isreached; adding a fifth object to said collection of objects at aposition that corresponds to a region of said method's instructions thatis executed if an exit point of said method will inevitably be reached;and, adding a sixth object to said collection of objects at a positionthat corresponds to a region of said method's instructions that will beexecuted if an error arises during execution of said method.
 29. Themachine readable storage medium of claim 28, wherein said classfile is aJava compatible classfile and said third, fifth and sixth objectscorrespond to the addition of invokestatic instructions.
 30. The machinereadable storage medium of claim 28, wherein said classfile is a Javacompatible classfile and said third, fifth and sixth objects correspondto the addition of invokevirtual instructions.
 31. A computing systemimplemented with a machine readable storage medium and/or memorycontaining instructions which when executed cause a classfilemodification method to be performed, said classfile modification methodcomprising: before loading and using a classfile to create an objectduring runtime; converting said classfile into a collection of objects,said collection of objects including a first object that represents amethod information structure found in said classfile, said collection ofobjections including a second object that inherits a property that saidfirst object has, said second object representing a bytecode instructionof a method; adding a third object to said collection of objects, saidthird object inheriting the properties of said first object, said thirdobject representing a bytecode instruction to be executed by said methodthat, when executed by said method, invokes a pre-existing dispatcher toidentify a plug-in module for said method that said method invokes toreport and/or record information about said method; adding a fourthobject to said collection of objects that represents a new methodinformation structure for said classfile, said new method informationstructure containing byte code instructions for a second method thatregisters, with said dispatcher upon loading of said classfile, anidentity of said classfile's class and respective identities of methodsof said classfile, said dispatcher and plug-in module being in existenceprior to said loading of said classfile; and, converting said collectionof objects including said third object into a modified version of saidclassfile.
 32. The computing system of claim 31, wherein said classfilemodification method further comprises adding a fifth object to saidcollection of objects that represents a new field information structurefor said classfile.
 33. The computing system of claim 32, wherein saidfield information structure is to store a numeric identificationassigned to said class by said dispatcher.
 34. The computing system ofclaim 31, wherein said third object is added to said collection ofobjects in a position that corresponds to a region of said method'sinstructions that is executed just after said method's entry point isreached.
 35. The computing system of claim 34, wherein said classfile isa Java compatible classfile and said adding of said third objectcorresponds to the addition of an invokestatic instruction.
 36. Thecomputing system of claim 34, wherein said classfile is a Javacompatible classfile and said adding of said third object corresponds tothe addition of an invokevirtual instruction.
 37. The computing systemof claim 31 wherein said adding at least one additional other objectfurther comprises adding an additional other object at a position thatcorresponds to a region of said unique method's instructions that isexecuted if an exit point of said unique method will inevitably bereached.
 38. The computing system of claim 37, wherein said third objectis added to said collection of objects at a position that corresponds toa region of said method's instructions that is executed if an exit pointof said method will inevitably be reached.
 39. The computing system ofclaim 37, wherein said classfile is a Java compatible classfile and saidadding of said third object corresponds to the addition of aninvokestatic instruction.
 40. The computing system of claim 31, whereinsaid third object is added to said collection of objects in a positionthat corresponds to a region of said method's instructions that will beexecuted if an error arises during execution of said method.
 41. Thecomputing system of claim 40, wherein said classfile is a Javacompatible classfile and said adding of said third object corresponds tothe addition of an invokestatic instruction.
 42. The computing system ofclaim 40, wherein said classfile is a Java compatible classfile and saidadding of said third object corresponds to the addition of aninvokevirtual instruction.
 43. The computing system of claim 31, whereinsaid classfile modification method further comprises: adding said thirdobject to said collection of objects at a position that corresponds to aregion of said method's instructions that is executed just after saidmethod's entry point is reached; adding a fifth object to saidcollection of objects at a position that corresponds to a region of saidmethod's instructions that is executed if an exit point of said methodwill inevitably be reached; and, adding a sixth object to saidcollection of objects at a position that corresponds to a region of saidmethod's instructions that will be executed if an error arises duringexecution of said method.
 44. The computing system of claim 43, whereinsaid classfile is a Java compatible classfile and said third, fifth andsixth objects correspond to the addition of invokestatic instructions.45. The computing system of claim 43, wherein said classfile is a Javacompatible classfile and said third, fifth and sixth objects correspondto the addition of invokevirtual instructions.